<?php class Characters { 

    /***
     * DB Fields: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id;

    /***
     * DB Fields: userId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $userId;

    /***
     * DB Fields: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $name;

    /***
     * DB Fields: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $description;

    /***
     * DB Fields: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $image;

    /***
     * DB Fields: raceId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $raceId;

    /***
     * DB Fields: personalityId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $personalityId;

    /***
     * DB Fields: level
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $level;

    /***
     * DB Fields: experience
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $experience;

    /***
     * DB Fields: universeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $universeId;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id
     **/
    function get_id( ) {
        // returns the value of id
        return $this->id;
    }


    /***
     * Get value for field: userId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result userId
     **/
    function get_userId( ) {
        // returns the value of userId
        return $this->userId;
    }


    /***
     * Get value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result name
     **/
    function get_name( ) {
        // returns the value of name
        return $this->name;
    }


    /***
     * Get value for field: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result description
     **/
    function get_description( ) {
        // returns the value of description
        return $this->description;
    }


    /***
     * Get value for field: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result image
     **/
    function get_image( ) {
        // returns the value of image
        return $this->image;
    }


    /***
     * Get value for field: raceId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result raceId
     **/
    function get_raceId( ) {
        // returns the value of raceId
        return $this->raceId;
    }


    /***
     * Get value for field: personalityId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result personalityId
     **/
    function get_personalityId( ) {
        // returns the value of personalityId
        return $this->personalityId;
    }


    /***
     * Get value for field: level
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result level
     **/
    function get_level( ) {
        // returns the value of level
        return $this->level;
    }


    /***
     * Get value for field: experience
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result experience
     **/
    function get_experience( ) {
        // returns the value of experience
        return $this->experience;
    }


    /***
     * Get value for field: universeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result universeId
     **/
    function get_universeId( ) {
        // returns the value of universeId
        return $this->universeId;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function set_id( $id ) {
        // sets the value of id
        $this->id = $id;
    }

    /***
     * Set value for field: userId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param userId
     * @result void
     **/
    function set_userId( $userId ) {
        // sets the value of userId
        $this->userId = $userId;
    }

    /***
     * Set value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param name
     * @result void
     **/
    function set_name( $name ) {
        // sets the value of name
        $this->name = $name;
    }

    /***
     * Set value for field: description
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param description
     * @result void
     **/
    function set_description( $description ) {
        // sets the value of description
        $this->description = $description;
    }

    /***
     * Set value for field: image
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param image
     * @result void
     **/
    function set_image( $image ) {
        // sets the value of image
        $this->image = $image;
    }

    /***
     * Set value for field: raceId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param raceId
     * @result void
     **/
    function set_raceId( $raceId ) {
        // sets the value of raceId
        $this->raceId = $raceId;
    }

    /***
     * Set value for field: personalityId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param personalityId
     * @result void
     **/
    function set_personalityId( $personalityId ) {
        // sets the value of personalityId
        $this->personalityId = $personalityId;
    }

    /***
     * Set value for field: level
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param level
     * @result void
     **/
    function set_level( $level ) {
        // sets the value of level
        $this->level = $level;
    }

    /***
     * Set value for field: experience
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param experience
     * @result void
     **/
    function set_experience( $experience ) {
        // sets the value of experience
        $this->experience = $experience;
    }

    /***
     * Set value for field: universeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param universeId
     * @result void
     **/
    function set_universeId( $universeId ) {
        // sets the value of universeId
        $this->universeId = $universeId;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: characters
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param userId
     * @param name
     * @param description
     * @param image
     * @param raceId
     * @param personalityId
     * @param level
     * @param experience
     * @param universeId
     * @result void
     **/
    function createnew_characters( $id, $userId, $name, $description, $image, $raceId, $personalityId, $level, $experience, $universeId ) {

        // items to be inserted in the database 
        $_obj = array($id,
                      $userId,
                      $name,
                      $description,
                      $image,
                      $raceId,
                      $personalityId,
                      $level,
                      $experience,
                      $universeId); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("characters", $_obj);
    }

    /***
     * Retrived an existing record: characters
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result new Characters
     **/
    function get_characters( $id ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM characters WHERE id = '$id'");

        $__charactersObj = new characters();
        // return the retrived from the database

        // create a new object
        $__obj = new Characters();
        $__obj->set_id($_resultSet[0]['id']);
        $__obj->set_userId($_resultSet[0]['userId']);
        $__obj->set_name($_resultSet[0]['name']);
        $__obj->set_description($_resultSet[0]['description']);
        $__obj->set_image($_resultSet[0]['image']);
        $__obj->set_raceId($_resultSet[0]['raceId']);
        $__obj->set_personalityId($_resultSet[0]['personalityId']);
        $__obj->set_level($_resultSet[0]['level']);
        $__obj->set_experience($_resultSet[0]['experience']);
        $__obj->set_universeId($_resultSet[0]['universeId']);


        return $__obj;
    }

    /***
     * Update an existing record: characters
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_characters( $id, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("characters", "id = '$id'");
    }

    /***
     * Delete an existing record: characters
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function delete_characters( $id ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("characters", "id = '$id'");
    }

    /***
     * Retrived list of objects base on a given parameters: characters
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Characters
     **/
    function list_characters( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM characters WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM characters";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Characters();

            $__newObj->set_id($__rs['id']);
            $__newObj->set_userId($__rs['userId']);
            $__newObj->set_name($__rs['name']);
            $__newObj->set_description($__rs['description']);
            $__newObj->set_image($__rs['image']);
            $__newObj->set_raceId($__rs['raceId']);
            $__newObj->set_personalityId($__rs['personalityId']);
            $__newObj->set_level($__rs['level']);
            $__newObj->set_experience($__rs['experience']);
            $__newObj->set_universeId($__rs['universeId']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>